import openpyxl
class OutputExcel:
    def __init__(self):
        self.workbook = openpyxl.Workbook()
        self.worksheet = self.workbook.active
    def out_data_to_excel(self, pathname, scorelistdict, majorlistdict, ranklistdict50, ranklistdict100, matchdict, averagedict):
        self.worksheet.title = pathname
        self.worksheet['A1'] = "班级"
        self.worksheet['B1'] = "成绩"

        for tmpdict in scorelistdict:
            for key in tmpdict:
                self.worksheet.append([key, tmpdict[key]])
            self.worksheet.append(["  "])

        self.worksheet.append(["专业课成绩"])
        for tmpdict in majorlistdict:
            for key in tmpdict:
                self.worksheet.append([key, tmpdict[key]])
            self.worksheet.append(["  "])

        self.worksheet.append(["rank50"])
        for tmpdict in ranklistdict50:
            for key in tmpdict:
                self.worksheet.append([key, tmpdict[key]])
            self.worksheet.append(["  "])

        self.worksheet.append(["rank100"])
        for tmpdict in ranklistdict100:
            for key in tmpdict:
                self.worksheet.append([key, tmpdict[key]])
            self.worksheet.append(["  "])

        self.worksheet.append(["匹配率"])
        for key in matchdict:
            self.worksheet.append([key, matchdict[key]])


        self.worksheet.append(["  "])
        self.worksheet.append(["年级均分"])
        for key in averagedict:
            self.worksheet.append([key, averagedict[key]])

        self.workbook.save("../EXCEL/" + pathname)






